#! /bin/bash

KVER=2.6.25
TCVER=5.1a

yum install fuse fuse-devel wxGTK wxGTK-devel

#yumdownloader --source kernel
#rpm -ivh kernel-$(uname -r).src.rpm

#rpmbuild -bp --target=noarch /usr/src/redhat/SPECS/kernel.spec
#cp /usr/src/redhat/BUILD/kernel-${KVER}/linux-${KVER}.noarch/drivers/md/dm.h /usr/src/kernels/`uname -r`-`uname -p`/drivers/md

#curl -O  http://www.truecrypt.org/downloads/truecrypt-${TCVER}-source-code.tar.gz

# So, of course, now the truecrypt people have added 
# spaces and capitalization into their download : Not-Very-UNIX
####curl -o truecrypt-${TCVER}-source-code.tar.gz "http://www.truecrypt.org/downloads/TrueCrypt\ ${TCVER}\ Source.tar.gz"
# Ahh, but that doesn't even work - they're now compelling the license verification for their source download...
# EeeDora looks fine (assuming they've got their source link somewhere in /usr/bin/truecrypt --help)

# For now, let's assume the download has been suitably renamed :
if [ -f "TrueCrypt\ ${TCVER}\ Source.tar.gz" ]; then 
 mv "TrueCrypt\ ${TCVER}\ Source.tar.gz" "truecrypt-${TCVER}-source-code.tar.gz"
fi
tar -xzf "truecrypt-${TCVER}-source-code.tar.gz"

#curl -O  http://www.linuxlove.org/for2.6.23.patch
#patch -p1 -i for2.6.23.patch

pushd .

cd truecrypt-${TCVER}-source

WX_TAR=wxWidgets-2.8.7.tar.gz
if [ ! -f "${WX_TAR}" ]; then 
 echo "Attempting to download the wxWidgets source from Sourceforge"
 curl -O http://internap.dl.sourceforge.net/sourceforge/wxwindows/${WX_TAR}
 if [ ! -f "${WX_TAR}" ]; then 
	 echo "Download failed - could you get ${WX_TAR} manually?"
	 exit 0
	fi
fi
tar -xzf ${WX_TAR}
WX_ROOT=`pwd`/wxWidgets-2.8.7 make wxbuild

# Patch  : need to add 
#include <cstring>
# into source/Platform/Memory.h


WX_ROOT=`pwd`/wxWidgets-2.8.7 make

popd

cp truecrypt-${TCVER}-source/Main/truecrypt .
#cp truecrypt-${TCVER}-source-code/Linux/Kernel/truecrypt.ko .

#rm -rf truecrypt-${TCVER}-source-code
